package com.clas.liu.myapplication.presenter.impl;

import android.os.Handler;
import android.os.Message;

import com.clas.liu.myapplication.model.entity.BaseRoot;
import com.clas.liu.myapplication.model.event.EditPasswordEvent;
import com.clas.liu.myapplication.model.impl.BaseModel;
import com.clas.liu.myapplication.model.impl.EditPasswordModel;
import com.clas.liu.myapplication.presenter.i.IEditPasswordPresenter;
import com.clas.liu.myapplication.view.activity.impl.BaseActivity;
import com.clas.liu.myapplication.view.activity.impl.EditPasswordActivity;

/**
 * Created by liu on 2019/5/2.
 */

public class EditPasswordPresenter extends BasePresenter<EditPasswordActivity, EditPasswordModel> implements IEditPasswordPresenter {

    public EditPasswordPresenter(EditPasswordActivity view) {
        super(view);
    }

    @Override
    public void editPassword(String phone, String pwd) {
        mModel.editPassword(phone, pwd);
    }

    @Override
    protected EditPasswordModel getModel(Handler handler) {
        return new EditPasswordModel(handler);
    }

    @Override
    protected void eventReceive(Message msg) {
        switch (msg.what) {
            case EditPasswordEvent.Edit_OK:
                BaseRoot root = ((EditPasswordEvent)msg.obj).getRoot();
                mView.postReturn(root.getCode(),root.getMessage());
                break;
            case EditPasswordEvent.EDIT_FAIL:
                mView.failBecauseNetReturn(msg.what);
                break;

        }
    }
}
